﻿Imports System
Imports System.Collections.Generic
Imports System.Windows
Imports System.Windows.Controls
Imports System.Windows.Data
Imports System.Windows.Input
Imports System.Windows.Media
Imports System.Windows.Media.Animation
Imports System.Windows.Media.Imaging
Imports System.Windows.Navigation
Imports System.Windows.Shapes

Namespace Views

    ''' <summary>
    ''' 
    ''' </summary>
    ''' <remarks></remarks>
    Partial Public Class ViewGraphEditor
        ''' <summary>
        ''' 
        ''' </summary>
        ''' <remarks></remarks>
        Public Sub New()
            MyBase.New()

            Me.InitializeComponent()

            ' Insert code required on object creation below this point.
        End Sub

        ''' <summary>
        ''' 
        ''' </summary>
        ''' <remarks></remarks>
        Private Sub VariablesInsertion(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs)
            Dim mi = TryCast(sender, MenuItem)
            If mi Is Nothing Then Return
            Dim dc = mi.DataContext.Caption 'Column.Value.chOutil.Nom
            If dc Is Nothing Then Return
            Dim cm = TryCast(ItemsControl.ItemsControlFromItemContainer(ItemsControl.ItemsControlFromItemContainer(mi)), ContextMenu)
            If cm Is Nothing Then Return
            Dim txt = TryCast(cm.PlacementTarget, TextBox)
            If txt Is Nothing Then Return
            txt.AppendText(dc.ToString())

        End Sub



    End Class
    Namespace Converters
        ''' <summary>
        ''' 
        ''' </summary>
        ''' <remarks></remarks>
        Public Class InvertConverter
            Implements IValueConverter

            ''' <summary>
            ''' 
            ''' </summary>
            ''' <remarks></remarks>
            Public Function Convert(ByVal value As Object, ByVal targetType As System.Type, ByVal parameter As Object, ByVal culture As System.Globalization.CultureInfo) As Object Implements System.Windows.Data.IValueConverter.Convert
                Try
                    Return Not CType(value, Boolean)
                Catch ex As Exception
                    Return Nothing
                End Try
            End Function
            ''' <summary>
            ''' 
            ''' </summary>
            ''' <remarks></remarks>
            Public Function ConvertBack(ByVal value As Object, ByVal targetType As System.Type, ByVal parameter As Object, ByVal culture As System.Globalization.CultureInfo) As Object Implements System.Windows.Data.IValueConverter.ConvertBack
                Try
                    Return Not CType(value, Boolean)
                Catch ex As Exception
                    Return Nothing
                End Try
            End Function
        End Class
    End Namespace

End Namespace